<?
include "Controladores/validaSesion.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>SRP | Historial Director</title>
             <link href="css/styles_director.css" rel="stylesheet" type="text/css" media="all" />
		<link href="font/stylesheet_tutores.css" rel="stylesheet" type="text/css" media="all" />
                <link rel="stylesheet" href="css/uniform.defaultstyle2.css" type="text/css" media="screen" />
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery.uniform.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" charset="utf-8">
      $(function(){
        $("input, select").uniform();
      });
    </script>
		<link rel="stylesheet" href="css/uniform.defaultstyle3.css" type="text/css" media="screen" />
                 <link rel="stylesheet" type="text/css" href="css/jquery.cleditor.css" />
                 
		<script src="YUI/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js" type="text/javascript"></script>
		<script src="YUI/2.6.0/build/calendar/calendar-min.js" type="text/javascript"></script>
		<script type="text/javascript">
 $(document).ready(function(){
     $('.ddm').hover(
	   function(){
		 $('.ddl').slideDown();
	   },
	   function(){
		 $('.ddl').slideUp();
	   }
	 );
 });
</script>
		<script type="text/javascript" src="js/DD_roundies_0.0.2a-min.js"></script>
		<script type="text/javascript">
DD_roundies.addRule('#tabsPanel', '5px 5px 5px 5px', true);

</script>
                <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.js"></script>
    <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
                 <script>
  
     $(function () {
    $("#1").click(function() {
        change(1);
    });
    });
     $(function () {
    $("#2").click(function() {
        change(2);
    });
    });
     $(function () {
    $("#3").click(function() {
        change(3);
    });
    });
    
    
    function getTextTA(id)
            {
                id+="Frame";
                var iFrame =  document.getElementById(id);
                var iFrameBody;
                if ( iFrame.contentDocument ) 
                { // FF
                    iFrameBody = iFrame.contentDocument.getElementsByTagName('body')[0];
                }
                else if ( iFrame.contentWindow ) 
                { // IE
                    iFrameBody = iFrame.contentWindow.document.getElementsByTagName('body')[0];
                }
                return (iFrameBody.innerHTML);
                
     }
     
     function setTextTA(id,val)
            {
                id+="Frame";
                var iFrame =  document.getElementById(id);
                var iFrameBody;
                if ( iFrame.contentDocument ) 
                { // FF
                    iFrameBody = iFrame.contentDocument.getElementsByTagName('body')[0];
                }
                else if ( iFrame.contentWindow ) 
                { // IE
                    iFrameBody = iFrame.contentWindow.document.getElementsByTagName('body')[0];
                }
                iFrameBody.innerHTML = val;
                
     }
    
    
    function enviarReporte()
     {
        if (confirm('Estan Correctos los Datos')){
            var FechaInfraccion = document.getElementById('FechaInfraccion').value;
            if(FechaInfraccion != "Fecha Infracción"){
                    enviar();
            }
            else alert("No Ha Seleccionado La Fecha de Infracción");
            
        }
     }
 
    function enviar()
     {
            var Tipo = getR();
            var FechaInfraccion = document.getElementById('FechaInfraccion').value;
            var Gravedad = document.getElementById('escondido').value;
            var Descripcion = getTextTA("input");
            var IdReporte = document.getElementById('IdReporte').value;
            var path= "Controladores/EditReporte.php?Tipo="+Tipo+"&FechaInfraccion="+FechaInfraccion+"&Gravedad="+Gravedad+"&Descripcion="+Descripcion+"&IdReporte="+IdReporte;

            $.ajax({
                'url' : path,'type' : 'GET',
                'success' : function(data) {

                }
            });
            alert("Se Ha Editado el Reporte");
            $( "#dialog-form" ).dialog( "close" );
         
     }
 
    function change(id)
      {
        var path = "images/apagado.png";
        $("#1").attr("src",path);
        $("#2").attr("src",path);
        $("#3").attr("src",path);
        switch(id)
        {
            case 1:
                $("#1").attr("src","images/verde.png");
                break;
            case 2:
                $("#2").attr("src","images/amarillo.png");
                break;
            case 3:
                $("#3").attr("src","images/rojo.png");
                break;
        }
        document.getElementById('escondido').value = (id-1);

     }
 
    function setR(val)
    {
        switch(parseInt(val))
                {
                    case 0:
                        document.getElementById('r0').checked = true;
                        break;
                    case 1:
                        document.getElementById('r1').checked = true;
                        break;
                    case 2:
                        document.getElementById('r2').checked = true;
                        break;
                    
                }
        
    }
    
    function getR()
    {
        if (document.getElementById('r0').checked)
            return 0;
        else if (document.getElementById('r1').checked)
            return 1;
        return 2;
    }
 
    function borrar(id)
    {
        if(confirm('Esta Seguro que Desea Borrar el Reporte?'))
        {
            
            var path= "Controladores/borrarReporte.php?Reporte="+id;
            $.ajax({
                'url' : path,'type' : 'GET',
                'success' : function(data) {

                }
            }); 
            var elem = document.getElementById(id);
            elem.parentNode.removeChild(elem);
            alert("Se Ha Eliminado el Reporte");
            
        }
    }
    
     function editar(id)
        {
        var path= "Controladores/GetReporte.php?Reporte="+id;        
        document.getElementById('IdReporte').value = id;
        $.ajax({
            'url' : path,'type' : 'GET',
            'success' : function(data) {
                limpiar();
                var n = data.split("}");
                document.getElementById('FechaReporte').value = n[0];
                document.getElementById('FechaInfraccion').value = n[1];
                document.getElementById('nombreA').innerHTML = n[6] + " <b>Matricula:</b> " +n[5];
                setTextTA("input", n[3]);
                setR(n[2]);
                /**/
                change(parseInt(n[4])+1);

                /**/
                document.getElementById('simon').style.visibility='visible'; // show 
                document.getElementById('cancelar').style.visibility='visible'; // show 
                $( "#dialog-form" ).dialog( "open" );
                document.getElementById("inputFrame").style.height="250px";
                
            }
        });  
        }
    
        function ver(id)
        {
        var path= "Controladores/GetReporte.php?Reporte="+id;        
        $.ajax({
            'url' : path,'type' : 'GET',
            'success' : function(data) {
                limpiar();
                var n = data.split("}");
                document.getElementById('FechaReporte').value = n[0];
                document.getElementById('FechaInfraccion').value = n[1];
                setTextTA("input", n[3]);
                document.getElementById('nombreA').innerHTML = n[6] + " <b>Matricula:</b> " +n[5];
                
                setR(n[2]);
                
                change(parseInt(n[4])+1);
                
                document.getElementById('simon').style.visibility='hidden'; // show 
                document.getElementById('cancelar').style.visibility='hidden'; // show 
                $( "#dialog-form" ).dialog( "open" );
                document.getElementById("inputFrame").style.height="250px";
                
            }
        });  
        }
        
        function limpiar()
        {

            change(1);
            var radios = document.getElementsByTagName('input');
            for (var i = 0; i < radios.length; i++) {
                if (radios[i].type === 'radio') {
                    // get value, set checked flag or do whatever you need to
                    radios[i].checked=true;
                    break;
                }
            }
            document.getElementById('FechaInfraccion').value = "Fecha Infracción";

        }

        function removerRow(trId) {
            $(document.getElementById(trId)).remove();
                
        }
 
        
        function startsWith(data,str)
        {
            var reg;
            if ((data.length >= str.length && data.substring(0, str.length) == str) || str == "search")
                reg = true;
            else
                reg = false;
            return reg;
        }
        
        function fillEntrada()
        { 
           $("#lst").empty();
           $("#lst").append("<li> <p class= 'title' ><strong>Fecha Reporte</strong></p> <p class='descripHead'>Alumno(s)</p> <p class='editHead'>Ver</p> <p class='editHead'>Borra</p> <p class='editHead'>Editar</p> </li>"); 
           var search = document.getElementById("search").value;
           var path= "Controladores/GetReportesProfesor.php";        
           $.ajax({
                'url' : path,'type' : 'GET',
                'success' : function(data) {
                      var ar = data.split("}");
                      if(ar.length > 1)
                        for(var x=0; x< ar.length;x++)
                        {
                            var nid = ar[x];
                            var way= "Controladores/GetReporte.php?Reporte="+nid;        
                            $.ajax({
                                'url' : way,'type' : 'GET',
                                'success' : function(info) {
                                        var arr = info.split("}");
                                        var fecha = arr[0];
                                        var nalumno = arr[5];
                                        var nid = arr[8];
                                        var nalumno = arr[6] + " -> " + arr[5];
                                        var algo = startsWith(arr[5],search);
                                        var algo = algo || startsWith(arr[6],search);
                                        if(algo == true){
                                            var id = "<li class=odd id ="+nid + ">";
                                            var FI  = "<p class=title>"+fecha+"</p>";
                                            var Al = "<p class=descrip id=alumnospar>"+nalumno+"</p>";
                                            var IdR =  "<p class=edit> <a onClick=ver("+nid+") class=pollo><img src=images/ver.png /></a></p>";
                                            var bR =  "<p class=edit> <a onClick=borrar("+nid+") class=pollo><img src=images/deletIco.png /></a></p>";
                                            var eR =  "<p class=edit> <a onClick=editar("+nid+") class=pollo><img src=images/editIco.png /></a></p>";
                                            var end = "</li>"; 
                                            var row;
                                            if(arr[9] == "0")
                                                row = id+ FI + Al + IdR + bR+eR+end;
                                            else row = id+ FI + Al + IdR + end;

                                            $("#lst").append(row);  
                                        }
                                    }
                                }); 

                        }
                     else if (data != "no")
                     {
                          var way= "Controladores/GetReporte.php?Reporte="+data;        
                          $.ajax({
                                'url' : way,'type' : 'GET',
                                'success' : function(info) {
                                        var arr = info.split("}");
                                        var fecha = arr[0];
                                        nid = arr[8];
                                        var nalumno = arr[6] + " -> " + arr[5];
                                        var algo = startsWith(arr[5],search);
                                        var algo = algo || startsWith(arr[6],search);
                                        if(algo == true){
                                            var id = "<li class=odd id ="+nid + ">";
                                            var FI  = "<p class=title>"+fecha+"</p>";
                                            var Al = "<p class=descrip id=alumnospar>"+nalumno+"</p>";
                                            var IdR =  "<p class=edit> <a onClick=ver("+nid+") class=pollo><img src=images/ver.png /></a></p>";
                                            var bR =  "<p class=edit> <a onClick=borrar("+nid+") class=pollo><img src=images/deletIco.png /></a></p>";
                                            var eR =  "<p class=edit> <a onClick=editar("+nid+") class=pollo><img src=images/editIco.png /></a></p>";
                                            var end = "</li>"; 
                                            var row;
                                            if(arr[9] == "0")
                                                row = id+ FI + Al + IdR + bR+eR+end;
                                            else row = id+ FI + Al + IdR + end;
                                            $("#lst").append(row);  
                                        }
                                    }
                                }); 
                         
                     }
                }
           }); 
           
           
        }
        $(function() {
            $( "#FechaInfraccion" ).datepicker();
        });
        
        $(function() { 
 
        $( "#dialog-form" ).dialog({
            autoOpen: false,
            width:940,
            modal: false,
            buttons: {                
            },
            close: function() {
                    allFields.val( "" ).removeClass( "ui-state-error" );
                }
            });
        });
        
    </script>
    <script type="text/javascript" src="src/jquery.autocomplete.js"></script>
    <script type="text/javascript" src="scripts/demo.js"></script>
                
		<script type="text/javascript" src="js/script-carasoul.js"></script>
		<link href="YUI/2.6.0/build/fonts/fonts-min.css" rel="stylesheet" type="text/css" />
		<link href="YUI/2.6.0/build/calendar/assets/skins/sam/calendar.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript">
	$(document).ready(function()
{

   $( '#checkall' ).live( 'click', function() {
				
				$( '.chkl' ).each( function() {
					$( this ).attr( 'checked', $( this ).is( ':checked' ) ? '' : 'checked' );
				}).trigger( 'change' );
 
			});
  $('#checkall').click(function(){


 $('span').toggleClass('checked');
$('#checkall').toggleClass('clicked');

 }); 
	});
		</script>
                <script type="text/javascript" src="js/jquery.cleditor.js"></script>
              
                  <script type="text/javascript">
      $(document).ready(function() {
        $("#input").cleditor(
			{
				width:        600, // width not including margins, borders or padding
                height:       350, // height not including margins, borders or padding
			}
							 );
      });
    </script>
		</head>
		<input type="hidden" id="escondido" value="0"/>
		<input type="hidden" id="IdReporte" value="0"/>
<div id="admin">
          <div id="wrap">
    <div id="head">
              <h1><a href="inicioProfesor.hp">SRP<br />
                <span>Sistema Reportes Preparatoria</span></a></h1>
              <ul id="menu">
                  <li><a href="inicioDirector.php">Inicio</a></li>
                  <li><a href="#">|</a></li>
                  <li><a href="Reportes/reporteDirector.pdf">Ayuda &nbsp;&nbsp;&nbsp;&nbsp;</a></li>
                  <li><a href="#">|</a></li>
                  <li><a href="Controladores/salir.php">Salir</a></li>
              </ul>
              <ul id="tablist">
        <li><a href="#a"><span>Home</span></a></li>
      </ul>
              <div id="tabsPanel">
        <div id="a" class="tab_content">
                  <div class='carousel_container'>
            <div class='left_scroll'><img src='images/leftArrow.png' alt="" /></div>
            <div class='carousel_inner'>
                      <ul class='carousel_ul'>
                         <li title="Cargar Reportes"><a class="ico5" href='cargarReportes.php'></a></li>
               
                         <li title="Nuevo Reporte"><a class="ico1" href='reporteDirector.php'></a></li>
                         <li title="Historial"><a class="ico6" href='historialDirector.php'>r</a></li>
                         <li title="Reportes"><a class="ico2" href='reportesDirector.php'></a></li> 
                         <li title="Inicio"><a class="ico4" href='inicioDirector.php'></a></li>
                         
                      </ul>
            </div>
            <div class='right_scroll'><img src='images/rightArrow.png' alt="" /></div>
          </div>
                </div>
        <div id="b" class="tab_content">
                  <div class='carousel_container'>
            <div class='left_scroll2'><img src='images/leftArrow.png' alt="" /></div>
           
            <div class='right_scroll2'><img src='images/rightArrow.png' alt="" /></div>
          </div>
                </div>
        <!--Tab End--> 
      </div>
              <img src="images/shadow.png" class="shadow" alt="" /> </div>

    <div id="content">
       <div class="datalist">
         <div class="styles">
        <div class="heading">
                  <h2>Historial Director</h2>
                  
                  <div class="search">
                    <input id="search" onchange="fillEntrada()"  name="search" type="text" value="search" onfocus="if(this.value=='search')this.value=''" onblur="if(this.value=='')this.value='search'" />
                    <input name="" type="submit" value="" />
                </div>
                      </div>
        </div>
           
        <ul id="lst">
          
          </ul>
      </div>
              
            
            </div>
  </div>
          <div class="push"></div>
        </div>
<div id="foot">
<p>© SRP</p>      
</div>


 <div id="dialog-form">
    <div id="content">
        <div class="forms">
        <div class="heading">
            <h2>Reporte <label id="nombreA">a</label></h2>
             <div class="nueva">
             <table border="1">
             <tr>
                <td>
                    <label>
                        Gravedad
                        <br></br>
                    </label>
                <label>
                </td>
             </tr>
             <tr>
                <td>
                    <img id="1" src="images/verde.png" alt="Image Button" />
                </td>
             </tr>
             <tr>
                 <td>
                    <img id="2" src="images/apagado.png" alt="Image Button"/>
                 </td>
             </tr>
             <tr>
                 <td>
                    <img id="3" src="images/apagado.png" alt="Image Button"/>
                </td>
             </tr>
             </table>
             </div>
              
             
            </div>
         <form class="styleForm">
             <div class="nueva2">
            
           <link href="content/styles.css" rel="stylesheet" /> 
         
        <div id="selection"></div>

             <p>Fecha Reporte &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;Fecha Infracción<br />
                 
                 <input readonly="true" name="fr" type="text" value="<?echo date('Y-m-d H:i:s');?>" id="FechaReporte" class="reg" onfocus="if(this.value=='Enter Title')this.value=''" onblur="if(this.value=='')this.value='Enter Title'" />
            
            <input style="margin-left: 10px" name="FechaInfraccion" type="text" value="Fecha Infracción" id="FechaInfraccion" class="reg" onfocus="if(this.value=='Fecha Infracción')this.value='';"  onblur="if(this.value=='')this.value='Fecha Infracción';"  /> 
            
          </p>
            
              <p>Tipo Reporte<br />
            <label>
                  <input type="radio" checked="true" name="RadioGroup1" value="Academico" id="r0" />
                  Académico</label>
            <label>
                  <input type="radio" name="RadioGroup1" value="Disciplinario" id="r1" />
                  Disciplinario</label>
            <label>
                  <input type="radio" name="RadioGroup1" value="Consejeria" id="r2" />
                  Consejería</label>
          </p>
            
                 <p>Descripción<br />
            
         
          <textarea id="input" name="input"></textarea>
 
            
            <p></p>
              
             <input name="save" id="simon" onClick="enviarReporte();" type="button" value="Aceptar" />
             <input name="ab"  id="cancelar"  onClick="limpiar();"     type="button" value="Cancelar" />
             </div>
            </form>
      </div>
              <img src="images/sepLine.png" alt="" class="sepline" />
            
          
            </div>
</div>
 
<script>
    fillEntrada();
</script>


</body>
</html>
